<template>
  <div>
    <van-nav-bar
      title="订单详情"
      @click-left="$router.go(-1)"
      left-text="返回"
      left-arrow
      :border="false"
    >
      <template #right>
        <van-icon name="ellipsis" size="25" />
      </template>
    </van-nav-bar>
    <div class="order_state"></div>
    <div class="order_wuliu">
      <div data-href="" data-progid="address" class="wuliu_cont">
        <div class="icon wl_pos_icon"></div>
        <div class="cont_text">
          <div class="wl_text">{{ address.uname }} {{ address.tel }}</div>
          <span class="wl_tip"
            >{{ address.address }}{{ address.addressDetail }}</span
          >
        </div>
        <!---->
        <!---->
      </div>
    </div>

    <div class="con_2" v-for="item in detailsList" :key="item.recID">
      <van-cell class="con_title" title="京东自营">
        <template #right-icon>
          <van-tag color="#ffe1e1" text-color="#ad0000"
            >共计{{ item.goodsNum }}件</van-tag
          >
        </template>
      </van-cell>
      <van-card
        :num="item.goodsNum"
        :price="item.GoodsPrice + '.00'"
        :desc="'颜色:' + item.Color + ',尺码/版本:' + item.Size"
        :title="item.GoodName"
        :thumb="item.GoodsPic"
      >
        <template #tags>
          <van-tag plain type="danger">精品好货</van-tag>
        </template>
      </van-card>
      <van-cell class="con_title_2">
        <template #title> </template>
        <template #right-icon> </template>
      </van-cell>
    </div>
    <van-collapse v-model="activeNames">
      <van-collapse-item name="1">
        <template #title>
          <span>订单编号：{{ $store.state.OrdersNum }}</span>
        </template>
        <template #right-icon>
          <span>应付金额：￥{{ amount }}</span>
        </template>
      </van-collapse-item>
    </van-collapse>
    <guessLike></guessLike>
  </div>
</template>
<script>
import guessLike from "../Children/GuessLike.vue";
export default {
  components: { guessLike },
  data() {
    return {
      activeNames: ["0"],
      detailsList: [],
      address: {
        uname: "",
        tel: "",
        address: "",
        addressDetail: "",
      },
    };
  },
  mounted() {
    this.QueryOrderAddress();
  },
  created() {
    this.QueryOrderdetails();
  },
  computed: {
    amount() {
      let a = 0;
      this.detailsList.forEach((x) => {
        a += x.GoodsPrice * x.goodsNum;
      });
      return a;
    },
  },
  methods: {
    async QueryOrderdetails() {
      const { data: res } = await this.$http.get("QueryOrderdetails", {
        params: { num: this.$store.state.OrdersNum },
      });
      this.detailsList = res.data;
      console.log(res);
    },
    async QueryOrderAddress() {
      try {
        const { data: res } = await this.$http.get("QueryOrderAddress", {
          params: { num: this.$store.state.OrdersNum },
        });
        this.address.uname = res.data.uname;
        this.address.tel = res.data.tel;
        this.address.address = res.data.address;
        this.address.addressDetail = res.data.addressDetail;
      } catch (error) {}
    },
  },
};
</script>
<style lang="less" scoped>
.order_state {
  position: relative;
  background: url(../../assets/icon/b3.png) repeat-y;
  color: #fff;
  padding: 64px 10px 30px;
  font-size: 13px;
  text-align: center;
  overflow: hidden;
  border: 1px solid;
  .state_txt {
    position: relative;
    font-size: 18px;
    line-height: 20px;
    font-weight: 500;
    z-index: 1;
    margin-bottom: 8px;
  }
  .icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 5px;
    background-image: url(https://img20.360buyimg.com/img/s80x80_jfs/t1/190532/19/15828/893/61029c93Eee4a7bad/a69e6e4fd423b1ba.png);
    background-size: 40px;
    background-repeat: no-repeat;
    vertical-align: -3px;
  }
  .state_time {
    background-position: 0 -20px;
  }
  .tip_item {
    position: relative;
    margin-top: 6px;
    display: inline-block;
    z-index: 1;
    text-align: left;

    margin-left: 15px;
  }
  .state_btn {
    margin-top: 15px;
    display: inline-block;
    background: #fff;
    box-shadow: 0 8px 16px 0 rgb(231 0 28 / 14%),
      inset 0 -4px 6px 0 rgb(255 198 198 / 77%);
    border-radius: 20px;
    position: relative;
    z-index: 1;
    color: #f2270c;
    padding: 10px 38px;
    line-height: 14px;
  }
}
.order_state + .order_wuliu {
  margin-top: -10px;
}
.order_wuliu {
  position: relative;
  background-color: #fff;
  border-radius: 10px;
  .wuliu_cont {
    padding: 11px 10px 12px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    position: relative;
  }
  .wl_pos_icon {
    background-position: -65px -22px;
    width: 16px;
    height: 19px;
  }
  .icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    background-image: url(https://wq.360buyimg.com/fd/h5/wxsq_dev/order/images/sprite_detail_xcxv2@2x_1553f337.png);
    background-size: 82.5px 79px;
    background-repeat: no-repeat;
  }
  .cont_text {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    position: relative;
  }

  .wl_text {
    font-size: 14px;
    line-height: 21px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .wl_tip {
    font-size: 12px;
    line-height: 18px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}
.con_2 {
  padding: 10px;
}
.con_title {
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
}
.van-card {
  margin-top: -1px;

  background: #fff;
}
.custom-title {
  line-height: 2.9rem;
}
.con_title_2 {
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
}
</style>